import Vue from 'vue'
import App from './App.vue'
import router from './router'
import '@/ElementUI/index'
// 导入字体图标
import '@/assets/global.css'
import store from './store'
import BRED from'@/components/BRED'
// 导入axios
import axios from 'axios'
import dayjs from 'dayjs'
// 配置Vue插件
Vue.prototype.$http = axios
Vue.config.productionTip = false
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
// 挂载原型
Vue.component(BRED.name, BRED)

axios.defaults.baseURL = '/api'
// 定义时间格式化函数
Vue.prototype.$formatDate = (dateObj) => {
  return dayjs(dateObj).format('YYYY-MM-DD HH:mm:ss')
}
Vue.config.productionTip = false
// 为每次一请求都在header中携带token
axios.interceptors.request.use(config => {
  console.log(window.sessionStorage.getItem('token'))
  // 每一次请求都携带
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})